package com.jeff.springbootdemo.config;

import com.jeff.springbootdemo.bean.Bus;
import com.jeff.springbootdemo.bean.Student;
import com.jeff.springbootdemo.bean.Teacher;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.*;

@Import(Student.class)
@Configuration(proxyBeanMethods = false)
@ImportResource("classpath:beans.xml")
public class MainConfig {

    @Bean
    public Student student() {
        Student stu = new Student("张三", 18, "男");
        stu.setTeacher(teacher());
        return stu;
    }

    @Bean
    public Teacher teacher() {
        return new Teacher("张月", 44, "女");
    }

    @ConditionalOnBean(name = "teacher1")
    @Bean
    public Teacher teacher01() {
        return new Teacher("王琪琪", 25, "女");
    }

    @Bean
    public Bus provide(){
        return new Bus();
    }
}
